<?php

use yii\db\Migration;

class m210222_083539_addon_overtime extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_overtime}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'merchant_id' => "int(11) NULL DEFAULT '0'",
            'cate_id' => "int(11) NOT NULL COMMENT '加班类型'",
            'member_id' => "int(11) NOT NULL DEFAULT '0' COMMENT '用户'",
            'begin_date' => "date NOT NULL COMMENT '开始时间'",
            'end_date' => "date NOT NULL COMMENT '结束时间'",
            'content' => "text NOT NULL COMMENT '加班理由'",
            'num' => "int(11) NOT NULL COMMENT '加班天数'",
            'remind' => "int(11) NOT NULL DEFAULT '0' COMMENT '提醒方式'",
            'log' => "json NULL COMMENT '审核日志'",
            'state' => "varchar(32) NULL COMMENT '工作流状态'",
            'sort' => "int(11) NULL DEFAULT '0'",
            'covers' => "text NULL",
            'status' => "varchar(32) NOT NULL DEFAULT 'apply' COMMENT '状态'",
            'created_at' => "int(11) NOT NULL COMMENT '创建时间'",
            'updated_at' => "int(11) NOT NULL COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='加班申请表'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_overtime}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

